package com.scrapy.http.get;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;

/**
 * 从网站上抓下来图片
 * Created by wanter on 2016/11/10.
 */
public class HttpPhoto {
            public static void main(String[] args) throws IOException {
                String urlAddress = "http://pic.qiushibaike.com/system/pictures/11780/117802560/medium/app117802560.jpg";
                URL url = new URL(urlAddress);
                URLConnection urlConnection = url.openConnection();
                InputStream inputStream = urlConnection.getInputStream();

        OutputStream opt = new FileOutputStream("photo/app11780256.jpg");


        int len = 0;
        byte[] byt = new byte[1024];
        while ((len = inputStream.read(byt))!=-1){
            opt.write(byt);
        }

        opt.close();
    }
}
